<?php /* Smarty version 2.6.26, created on 2013-10-30 09:44:28
         compiled from ../templates/front/js/flow.js */ ?>
function region(obj, id){
	$.ajax({
		url: "flow.php?act=regionSearch&region_id=" + $("#"+id).val(),
		type: "GET",
		data: "json",
		cache: false,
		success: function(data) {
			var select = $("#"+id).next();
			var json = JSON.parse(data);
			var key = json.length-1;
			if(json[key]['region_id'] > 1){
				if(1 < json[key]['region_id'] && json[key]['region_id'] < 36){
					var opt = '请选择省';
				}else if(35 < json[key]['region_id'] && json[key]['region_id'] < 398){
					var opt = '请选择市';
				}else if(397 < json[key]['region_id']){
					var opt = '请选择区';
				}
				
				var str = '<option value="0" selected="selected">' + opt + '</option>';
				for(var i=0,len=json.length; i<len; i++){
					str += '<option value="' + json[i]['region_id'] + '">' + json[i]['region_name'] + '</option>';
				}
				
				select.empty();
				select.append(str);
				if(opt == '请选择省'){
					select.next().empty();
					select.next().append('<option value="0" selected="selected">请选择市</option>');
					select.next().next().empty();
					select.next().next().append('<option value="0" selected="selected">请选择区</option>');
				}else if(opt == '请选择市'){
					select.next().empty();
					select.next().append('<option value="0" selected="selected">请选择区</option>');
				}
			}else{
				select.empty();
				select.append('<option value="0" selected="selected">请选择省</option>');	
				select.next().empty();
				select.next().append('<option value="0" selected="selected">请选择市</option>');
				select.next().next().empty();
				select.next().next().append('<option value="0" selected="selected">请选择区</option>');
			}
			
		}
	});
}

/** POST
url: "flow.php",
type: "POST",
data: {act:"regionSearch", region_id:obj.value},
html
*/ 

/**
function getxhr(){
	var xhr = false;
	if(window . XMLHttpRequest){
		xhr = new XMLHttpRequest();
	}else{
		xhr = window . ActiveXObject('Microsoft . XMLHttp');
	}
	return xhr;
}

function region(obj, id){
	
	var xhr = getxhr();
	var url = 'flow.php?act=regionSearch&region_id=' + obj.value;

	xhr.open('GET', url, true);
	xhr.onreadystatechange = function (){
		if(xhr.readyState == 4){
		
			var regionList = eval('(' + this.responseText + ')');
			
		}
	}
	
}
*/
